<% enabled_plugins = PluginRoutes.enabled_plugins(current_site) %>
<div class="panel panel-default">
    <div class="panel-body">

        <table class="table table-responsive table-hover table-striped">
            <thead>
            <tr>
                <th><%= t('zerocms.admin.table.title') %></th>
                <th><%= t('zerocms.admin.table.description') %></th>
                <th><%= t('zerocms.admin.table.version') %></th>
                <th><%= t('zerocms.admin.table.status') %></th>
                <th><%= t('zerocms.admin.table.actions') %></th>
            </tr>
            </thead>
            <tbody>
            <% plugins.each do |plugin| status = enabled_plugins.include?(plugin); r = {links: ["Version: #{plugin["version"]}"], plugin: plugin}; %>
                <tr>
                    <td>
                        <b><%= plugin["title"] %></b>
                        <br>
                        <% # sample:
                           # def zerocms_stripe_donation_plugin_options(args)
                           #   args[:links] << link_to('Settings', admin_plugins_zerocms_stripe_donation_settings_path)
                           # end %>
                        <% hook_run(plugin, "plugin_options", r) if status %>
                        <%= raw r[:links].join(" | ") %>
                    </td>
                    <td><%= raw plugin["descr"] %></td>
                    <td><%= plugin["version"] %></td>
                    <td><%= t("zerocms.admin.plugins.status_#{status}") %></td>
                    <td>
                        <%= link_to raw("<i class='fa fa-#{status ? "check-square" : "square"}'></i>"), {action: :toggle, id: plugin["key"], status: status }, class: "btn btn-default btn-xs", title: "#{status ? t('zerocms.admin.button.disable_plugin') : t('zerocms.admin.button.activate_plugin') }", data: { confirm: "#{"#{status ? t('zerocms.admin.button.disable_plugin') : t('zerocms.admin.button.activate_plugin') }"}?" } %>
                        <%= link_to("<i class='fa fa-arrow-circle-o-up'></i>".html_safe, zerocms_admin_plugin_upgrade_path(plugin["key"]), class: "btn btn-info btn-xs", title: "#{t("zerocms.admin.plugins.upgrade_to")} #{plugin["version"]}") if status && current_site.get_plugin(plugin["key"]).old_version? %>
                    </td>
                </tr>
            <% end %>

            </tbody>
        </table>
        <%= content_tag("div", raw(t('zerocms.admin.message.data_found_list')), class: "alert alert-warning") if plugins.empty? %>
    </div>
</div>